package com.itetchologyandenglish.home.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itetchologyandenglish.home.enetity.News;
import com.itetchologyandenglish.home.mapper.NewsMapper;
import com.itetchologyandenglish.home.service.NewsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class NewsServiceImpl implements NewsService {
    @Resource
    NewsMapper newsMapper;
    @Override
    public PageInfo getNewsByNewstitleAndNewsdate(Integer pn, String newstitle, String newsdate,Integer limit,Integer deflag) {
        PageHelper.clearPage();
        PageHelper.startPage(pn,limit);
        List<News> newList=newsMapper.getNewsByNewstitleAndNewsdate(newstitle,newsdate,deflag);
        PageInfo pgeInfo=new PageInfo(newList);
        return pgeInfo;
    }

    @Override
    public News findNewsById(Integer id) {
        return newsMapper.findNewsById(id);
    }

    @Override
    public boolean updatenews(News news) {
        return  newsMapper.updatenews(news)>0? true:false;
    }

    @Override
    public boolean delnews(Integer id) {
        return newsMapper.delnews(id)>0?true:false;
    }

    @Override
    public boolean savenews(News news) {
        return newsMapper.savenews(news)>0?true:false;
    }
}
